package com.googlecode.davdroid;

import java.util.Collections;
import java.util.List;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class HelloAndroidActivity extends ListActivity {

    private static String TAG = "davdroid";

    private ListView serverView = null;

    private ListView getServerView() {
        if(serverView == null) {
        	final Context context = getApplicationContext();
            serverView = new ListView(context);
            List<Server> servers = Collections.singletonList(one);
            for(Server server : servers) {
            	TextView tv = new TextView(context);
            	tv.setTag(server);
            	tv.setText(server.toString());
                serverView.addView(tv);
            }
            serverView.setTextFilterEnabled(true);
            serverView.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                  // When clicked, show a toast with the TextView text
                  Toast.makeText(context, ((TextView) view).getText(),
                      Toast.LENGTH_SHORT).show();
                }
              });
        }
        return serverView;
    }

    /**
     * Called when the activity is first created.
     * @param savedInstanceState If the activity is being re-initialized after 
     * previously being shut down then this Bundle contains the data it most 
     * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b>
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		Log.i(TAG, "onCreate");
        Server one = new Server("1&1", "https://sd2dav.1und1.de", "ulikoehler@online.de", "unoid1Vawo");
		List<Server> servers = Collections.singletonList(one);
    }

}

